﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeChatJumpGameHelper
{
    public static class ExtensionMethods
    {
        public static readonly int similarity = 5;
        public static bool isSimilarColor(this Color color1, Color color2)
        {
            //return Math.Abs(color1.R - color2.R) <= similarity
            //    && Math.Abs(color1.G - color2.G) <= similarity
            //    && Math.Abs(color1.B - color2.B) <= similarity;
            return Math.Abs(color1.R - color2.R) <= 2 * similarity
                && Math.Abs(color1.G - color2.G) <= 2 * similarity
                && Math.Abs(color1.B - color2.B) <= 2 * similarity
                && (Math.Abs(color1.R - color2.R) + Math.Abs(color1.G - color2.G) + Math.Abs(color1.B - color2.B)) <= 3 * similarity;
        }
    }
}
